package com.moju.serviceImpl;

import com.moju.mapper.UserMapper;
import com.moju.pojo.User;
import com.moju.service.UserService;
import com.moju.util.SqlSessionUtil;
import org.apache.ibatis.session.SqlSession;

public class UserServiceImpl implements UserService {


    @Override
    public User getUserByUserNameAndPwd(String userName, String pwd) throws Exception {

        SqlSession sqlSession = SqlSessionUtil.getSqlSession();
        //多态
        UserMapper mapper = sqlSession.getMapper(UserMapper.class);

        User user = mapper.getUserByUserNameAndPwd(userName, pwd);

        return user;
    }

    @Override
    public int deleteUserByIds(int[] ids) throws Exception {

        SqlSession sqlSession = SqlSessionUtil.getSqlSession();
        //多态
        UserMapper mapper = sqlSession.getMapper(UserMapper.class);

        int a = mapper.deleteUsersByIds(ids);

        return a;
    }

    @Override
    public int insertUser(User user) throws Exception {
        SqlSession sqlSession = SqlSessionUtil.getSqlSession();
        //多态
        UserMapper mapper = sqlSession.getMapper(UserMapper.class);

        int a = mapper.insertUser(user);

        return  a;
    }


}
